#ifndef _LED_H
#define _LED_H

#include "sn_config.h"

enum LED_STATE
{
    LED_STATE_ON,
    LED_STATE_OFF,
    LED_STATE_BLK,
};
#define LED_MAX_NUM 3

#define LED_NUM_RUNNING     0
#define LED_NUM_ALARMED     2
#define LED_NUM_WARNING     1
struct led_object
{
    uint8_t num;//编号
    uint16_t blk_val;//闪烁设定值，闪烁时间规零后赋值
    uint16_t blk_cnt;//闪烁时间
	uint16_t blk_setval;
    enum LED_STATE state;
    void    (*on)       (void);//打开
    void    (*off)      (void);//关闭
    void    (*toggle)   (void);//切换
    uint8_t (*pin_state) (void);//引脚状态
};
struct led_dev_t
{
    uint8_t led_count;//led 个数    
    uint8_t std_state;//标准状态
    struct led_object obj[LED_MAX_NUM];
    /**
     * @brief 设置led 的闪烁值
     * 
     */
    int (*set_led_blk)(struct led_dev_t *dev , uint8_t num,uint16_t val);
    /**
     * @brief 设置led 状态
     * 
     */
    int (*modify_state)(struct led_dev_t *dev , uint8_t num,enum LED_STATE state);
    /**
     * @brief 设置led 执行状态
     * 
     */
    int (*set_state)(struct led_dev_t *dev , uint8_t num);
    /**
     * @brief 获取led 当前状态
     * 
     */
   enum LED_STATE (*get_state)(struct led_dev_t *dev , uint8_t num);
    /**
     * @brief 此函数为led的循环调用函数应该在500ms定时器函数中执行
     * 
     */
    int (*timer_callback)(struct led_dev_t *dev);
    /**
     * @brief 通过此函数，用户可以得到设备指针
     * 
     */
   struct led_dev_t *(*get_device_ponter)(void);
};
void led_init(struct led_dev_t **dev);
#endif // !_LED_H

